home *** CD-ROM | disk | FTP | other *** search
/ Programming Sound Cards / Programming Sound Cards.iso / sound_52 / chords.ma < prev    next >
Text File  |  1995-01-01  |  8KB  |  457 lines

  1. #
  2. # chords.ma
  3. # Library for chords. 
  4. # This module implements a chord package.
  5. # The chords per se are jazz oriented.
  6. #
  7. # The following entities are defined:
  8. #
  9. # 1. a set of constants to be used as array indices.
  10. # The first character is capitalized. This permits
  11. # them to be distinquished from scales which are uppercase.
  12. # 2. an array of chord sizes.
  13. #     uchar chordSizes[NOCHORDS]
  14. # 3. an array of chords with offsets defining the chord.
  15. #       uchar chordNotes[NOCHORDS][MAXCHORD]
  16. # Each chord is terminated by -1.
  17. #
  18. # 4. Several useful functions: 
  19. #    riff wprintChord(whandle, root, index) - print the string name of the chord
  20. #    riff doChord(base, vector v, size, time, velocity)
  21. #        - play the chord
  22. #    riff testChordArrays() - simple test of arrays
  23. #
  24.  
  25.  
  26. export
  27.     chordSizes,
  28.     chordNotes,
  29.     wprintChord,
  30.     doChord
  31. end
  32.  
  33. @include \mh\chords.mh
  34.  
  35. uchar chordSizes[NOCHORDS]={
  36. # major chords
  37. # Major 
  38. 3,
  39. # Major6
  40. 4,
  41. # Major7
  42. 4,
  43. # Major79
  44. 5,
  45. # Major9
  46. 4,
  47. # Major69
  48. 5,
  49. # Major7b5
  50. 4, 
  51. # Major69b5
  52. 5,
  53. # Major9b5
  54. 4,
  55. # Major911
  56. 5,
  57. # Major7911
  58. 6,
  59. # # minor chords
  60. # Minor 
  61. 3,
  62. # Minor6
  63. 4,
  64. # Minor7
  65. 4,
  66. # Minor79
  67. 5,
  68. # Minor11
  69. 4,
  70. # MinorMaj7
  71. 4,
  72. # Minor7b5
  73. 4,
  74. # Minor711
  75. 5,
  76.   
  77. # # dominant chords, augmented on 7,9,11,13
  78. # Dom7 
  79. 4,
  80. # Dom7b5
  81. 4,
  82. # Dom79 
  83. 5,
  84. # Dom711
  85. 5,
  86. # Dom7913
  87. 6,
  88. # Dom713
  89. 5,
  90. # Dom7b59
  91. 6,
  92. # Dom7b9#11
  93. 6,
  94. # Dom7#5
  95. 4,
  96. # Dom7#9
  97. 5,
  98. # Dom7b9
  99. 5,
  100. # Dom7#5b9
  101. 5,
  102. # # misc
  103. # Augmented
  104. 3,
  105. # Dim7    
  106. 4,
  107. # Fifths2
  108. 2,
  109. # Fifths3
  110. 3,
  111. # Fifths4
  112. 4,
  113. # Fifths5
  114. 5,
  115. # Fifths6
  116. 6,
  117. # Fourths2
  118. 2,
  119. # Fourths3
  120. 3,
  121. # Fourths4
  122. 4,
  123. # Fourths5
  124. 5,
  125. # Forths6
  126. 6,
  127. # Octaves2    
  128. 2,
  129. # Octaves3
  130. 3,
  131. # Octaves4
  132. 4,
  133. # Octaves5
  134. 5,
  135. # Octaves6
  136. 6, 
  137. # Minor47
  138. 4
  139. }
  140.   
  141. # chordNotes - this table defines the notes in a chord.
  142. # chordtype can be mapped to chord notes.
  143. #
  144. # Each row gives:
  145. # no of notes in chord, followed by offsets for chord.
  146. # MAXCHORD defines the max. number of notes in a chord.
  147. #
  148. uchar chordNotes[NOCHORDS][MAXCHORD]={
  149. # major chords
  150.  
  151. # Major
  152. 0,4,7,                {-1},0,0,0,
  153. # Major6
  154. 0,4,7,9,            {-1},0,0,
  155. # Major7
  156. 0,4,7,11,            {-1},0,0,
  157. # Major79
  158. 0,4,7,11,14,            {-1},0,
  159. # Major9
  160. 0,4,7,14,            {-1},0,0,
  161. # Major69
  162. 0,4,7,9,14,            {-1},0,
  163. # Major7b5
  164. 0,4,6,11,            {-1},0,0,
  165. # Major9b5
  166. 0,4,6,14,            {-1},0,0,
  167. # Major69b5
  168. 0,4,6,7,14,            {-1},0,
  169. # Major911
  170. 0,4,7,14,17,            {-1},0,
  171. # Major7911
  172. 0,4,7,11,14,17,            {-1},
  173.  
  174. # minor chords
  175. # Minor 
  176. 0,3,7,                {-1},0,0,0,
  177. # Minor6
  178. 0,3,7,9,            {-1},0,0,
  179. # Minor7
  180. 0,3,7,10,            {-1},0,0,
  181. # Minor79
  182. 0,3,7,10,14,            {-1},0,
  183. # Minor11
  184. 0,3,7,17,             {-1},0,0,
  185. # MinorMaj7
  186. 0,3,7,11,            {-1},0,0,
  187. # Minor7b5
  188. 0,3,6,10,            {-1},0,0, 
  189. # Minor711
  190. 0,3,7,10,17,             {-1},0,
  191.  
  192. # dominant chords, augmented on 7,9,11,13
  193. # Dom7   
  194. 0,4,7,10,            {-1},0,0,
  195. # Dom7b5
  196. 0,4,6,10,            {-1},0,0,
  197. # Dom79
  198. 0,4,7,10,14,            {-1},0,
  199. # Dom711
  200. 0,4,7,10,17,            {-1},0,
  201. # Dom7913
  202. 0,4,7,10,14,21,            {-1},
  203. # Dom713
  204. 0,4,7,10,21,            {-1},0,
  205. # Dom7b59
  206. 0,4,6,10,13,            {-1},0,
  207. # Dom7b9#11
  208. 0,4,7,10,13,18,            {-1},
  209. # Dom7#5
  210. 0,4,8,10,            {-1},0,0,
  211. # Dom7#9
  212. 0,4,7,10,15,            {-1},0,
  213. # Dom7b9
  214. 0,4,7,10,13,            {-1},0,
  215. # Dom7#5b9
  216. 0,4,8,10,13,            {-1},0,
  217.  
  218. # misc
  219.  
  220. # Augmented
  221. 0,4,8,                {-1},0,0,0,
  222. # Dim7    
  223. 0,3,6,9,            {-1},0,0,
  224. # Fifths2
  225. 0,7,                {-1},0,0,0,0,
  226. # Fifths3
  227. 0,7,14,                {-1},0,0,0,
  228. # Fifths4
  229. 0,7,14,21,            {-1},0,0,
  230. # Fifths5
  231. 0,7,14,21,28,            {-1},0,
  232. # Fifths6
  233. 0,7,14,21,28,30,        {-1},
  234. # Fourths2
  235. 0,5,                {-1},0,0,0,0,
  236. # Fourths3
  237. 0,5,10,                {-1},0,0,0,
  238. # Fourths4
  239. 0,5,10,15,            {-1},0,0,
  240. # Fourths5
  241. 0,5,10,15,20,            {-1},0,
  242. # Fourths6, scriabin's mystic chord
  243. 0,5,10,15,20,25,        {-1},
  244. # Octaves2
  245. 0,12,                {-1},0,0,0,0,
  246. # Octaves3
  247. 0,12,24,            {-1},0,0,0,
  248. # Octaves4
  249. 0,12,24,36,            {-1},0,0,
  250. # Octaves5
  251. 0,12,24,36,48,            {-1},0,
  252. # Octaves6
  253. 0,12,24,36,48,60,        {-1}, 
  254. #
  255. # misc. chords
  256. #
  257. # Minor47, 4th instead of 3rd
  258. 0,4,7,10,            {-1},0,0 
  259. }
  260.  
  261. #
  262. # given the index, print the name of the chord
  263. #
  264. riff wprintChord(wd, root, index)
  265.      switch(index)  
  266.      case Major:
  267.          void wprintf(wd, "%n Major", root)
  268.      end
  269.      case Major6:
  270.          void wprintf(wd,"%n Major6", root)
  271.      end
  272.      case Major7:
  273.          void wprintf(wd,"%n Major7", root)
  274.      end
  275.      case Major79:
  276.          void wprintf(wd,"%n Major79", root)
  277.      end
  278.      case Major9:
  279.          void wprintf(wd,"%n Major9", root)
  280.      end
  281.      case Major69:
  282.          void wprintf(wd,"%n Major69", root)
  283.      end
  284.      case Major7b5:
  285.          void wprintf(wd,"%n Major7b5", root)
  286.      end
  287.      case Major69b5:
  288.          void wprintf(wd,"%n Major69b5", root)
  289.      end
  290.      case Major9b5:
  291.          void wprintf(wd,"%n Major9b5", root)
  292.      end
  293.      case Major911:
  294.          void wprintf(wd,"%n Major911", root)
  295.      end
  296.      case Major7911:
  297.          void wprintf(wd,"%n Major7911", root)
  298.      end
  299.      case Minor:
  300.          void wprintf(wd,"%n Minor", root)
  301.      end
  302.      case Minor6:
  303.          void wprintf(wd,"%n Minor6", root)
  304.      end
  305.      case Minor7:
  306.          void wprintf(wd,"%n Minor7", root)
  307.      end
  308.      case Minor79:
  309.          void wprintf(wd,"%n Minor79", root)
  310.      end
  311.      case Minor11:
  312.          void wprintf(wd,"%n Minor11", root)
  313.      end
  314.      case MinorMaj7:
  315.          void wprintf(wd,"%n MinorMaj7", root)
  316.      end
  317.      case Minor7b5:
  318.          void wprintf(wd,"%n Minor7b5", root)
  319.      end
  320.      case Minor711:
  321.          void wprintf(wd,"%n Minor711", root)
  322.      end
  323.      case Minor11:
  324.          void wprintf(wd,"%n Minor11", root)
  325.      end
  326.      case Dom7:
  327.          void wprintf(wd,"%n Dom7", root)
  328.      end
  329.      case Dom7b5:
  330.          void wprintf(wd,"%n Dom7b5", root)
  331.      end
  332.      case Dom79:
  333.          void wprintf(wd,"%n Dom79", root)
  334.      end
  335.      case Dom711:
  336.          void wprintf(wd,"%n Dom711", root)
  337.      end
  338.      case Dom7913:
  339.          void wprintf(wd,"%n Dom7913", root)
  340.      end
  341.      case Dom713:    
  342.          void wprintf(wd,"%n Dom713", root)
  343.      end
  344.      case Dom7b59:
  345.          void wprintf(wd,"%n Dom7b59", root)
  346.      end
  347.      case Dom7b9#11:
  348.          void wprintf(wd,"%n Dom7b9#11", root)
  349.      end
  350.      case Dom7#5:
  351.          void wprintf(wd,"%n Dom7#5", root)
  352.      end
  353.      case Dom7#9:
  354.          void wprintf(wd,"%n Dom7#9", root)
  355.      end
  356.      case Dom7b9:    
  357.          void wprintf(wd,"%n Dom7b9", root)
  358.      end
  359.      case Dom7#5b9:    
  360.          void wprintf(wd,"%n Dom7#5b9", root)
  361.      end
  362.      case Augmented:
  363.          void wprintf(wd,"%n Augmented", root)
  364.      end
  365.      case Dim7:
  366.          void wprintf(wd,"%n Dim7", root)
  367.      end
  368.      case Fifths2:
  369.          void wprintf(wd,"%n Fifths2", root)
  370.      end
  371.      case Fifths3:
  372.          void wprintf(wd,"%n Fifths3", root)
  373.      end
  374.      case Fifths4:
  375.          void wprintf(wd,"%n Fifths4", root)
  376.      end
  377.      case Fifths5:
  378.          void wprintf(wd,"%n Fifths5", root)
  379.      end
  380.      case Fifths6:
  381.          void wprintf(wd,"%n Fifths6", root)
  382.      end
  383.      case Fourths2:
  384.          void wprintf(wd,"%n Fourths2", root)
  385.      end
  386.      case Fourths3:
  387.          void wprintf(wd,"%n Fourths3", root)
  388.      end
  389.      case Fourths4:    
  390.          void wprintf(wd,"%n Fourths4", root)
  391.      end
  392.      case Fourths5:
  393.          void wprintf(wd,"%n Fourths5", root)
  394.      end
  395.      case Fourths6:
  396.          void wprintf(wd,"%n Fourths6", root)
  397.      end
  398.      case Octaves2:
  399.          void wprintf(wd,"%n Octaves2", root)
  400.      end
  401.      case Octaves3:
  402.          void wprintf(wd,"%n Octaves3", root)
  403.      end
  404.      case Octaves4:
  405.          void wprintf(wd,"%n Octaves4", root)
  406.      end
  407.      case Octaves5:
  408.          void wprintf(wd,"%n Octaves5", root)
  409.      end
  410.      case Octaves6:
  411.          void wprintf(wd,"%n Octaves6", root)
  412.     end
  413.     case Minor47:
  414.          void wprintf(wd,"%n Minor47", root)
  415.      end
  416.      end
  417. end
  418.  
  419. # doChord
  420. #
  421. # Params:
  422. # base: root note for chord
  423. # v: 1 dim array chord offsets are stored in.
  424. # size: notes in chord
  425. # time: time for chord
  426. # velocity: velocity for chord 
  427. # play chords stored as offsets in arrays
  428. #
  429. # may be looking at a prototype C function here
  430. # this should be a ravel function.
  431. #
  432. riff doChord(base, vector v, size, time, velocity)
  433.     int index
  434.  
  435.     size--
  436.     for (index = 0; index < size; index++)
  437.         base+v[index] 0,time velocity
  438.     end
  439.     base+v[size] time velocity
  440. end
  441.  
  442. #vco testChordArrays()
  443. #    int i
  444. #
  445. #    for ( i = 0; i < NOCHORDS; i++)
  446. #        NEEDS WORK HERE!!!
  447. #        void printChord(i)
  448. #        void doChord(LE,&chordNotes[i],chordSizes[i],h,forte)
  449. #    end
  450. #end
  451.  
  452.